package com.qf.shop.common.redis.config;

import com.alibaba.fastjson.support.spring.FastJsonRedisSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;

/**
 * @author: admin
 * @time: 2022/5/18 1:51
 */
public class RedisConfig {

    @Autowired
    @Bean
    public RedisTemplate redisTemplate(RedisTemplate redisTemplate) {
        FastJsonRedisSerializer jsonRedisSerializer = new FastJsonRedisSerializer(Object.class);

        redisTemplate.setKeySerializer(RedisSerializer.string());
        redisTemplate.setValueSerializer(jsonRedisSerializer);

        redisTemplate.setHashKeySerializer(RedisSerializer.string());
        redisTemplate.setHashValueSerializer(jsonRedisSerializer);
        return redisTemplate;
    }



}

